<template>
  <div class="app-container">
    <!--    隐藏域 记录id-->

    <el-form ref="form" :model="rule" label-width="120px">
      <el-form-item label="限制借阅数量">
        <el-input type="text" v-model="rule.num" />
      </el-form-item>
      <el-form-item label="限制借阅天数">
        <el-input  type="text" v-model="rule.days" />
      </el-form-item>
      <el-form-item label="图书超期每天的费用">
        <el-input  type="text" v-model="rule.rules" />
      </el-form-item>


      <el-form-item>
        <el-button type="primary"  @click="onSubmit">新增规则</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      rule:{
        id:0,
        num:null,
        days:null,
        rules:null
      },

    }
  },
  mounted() {

  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url:"/library/rule/save.do",
        method: "POST",
        data:this.rule
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/rulelist");
        }
      })
    },
    checkPass() {},
    onCancel() {
      this.$message({
        message: '取消规则的新增',
        type: 'warning'
      }),
        this.$router.push("/rulelist");
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

